package com.hxgis.oc.util.w3d.base;

import com.hxgis.oc.config.OConfig;
import com.hxgis.oc.util.CommandInvoker;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.IOException;

@Slf4j
@Component
public class W3dConvert {
    public static boolean executeCommand(String fileName, String w3dmFileName,String varName) throws IOException, InterruptedException {
        String application = OConfig.getConfig().getOCApplication();
        String command[] = {fileName,w3dmFileName,varName};
        return CommandInvoker.invoke(application,command);
    }

    public static boolean convert(File rawFile, File w3dmFile, String varName) throws IOException, InterruptedException {
        return executeCommand(rawFile.getAbsolutePath(),w3dmFile.getAbsolutePath(),varName);
    }
}
